/*    */ package dm.jdbc.driver;
/*    */ 
/*    */ import dm.jdbc.dataConvertion.Convertion;
/*    */ import dm.jdbc.dbaccess.DBError;
/*    */ import dm.jdbc.dbaccess.DmMsgSend;
/*    */ import java.sql.Clob;
/*    */ import java.sql.SQLException;
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DmClobBinder
/*    */   extends DmBinder
/*    */ {
/* 14 */   boolean new_lob_flag = false;
/*    */   
/*    */   public DmClobBinder(DmdbPreparedStatement_bs pstmt) {
/* 17 */     super(pstmt);
/* 18 */     this.new_lob_flag = pstmt.getConnection_bs().getNewLobFlag();
/*    */   }
/*    */   
/*    */   void init() {
/* 22 */     this.recDType = 19;
/* 23 */     this.recPrec = Integer.MAX_VALUE;
/* 24 */     this.recScale = 0;
/*    */   }
/*    */   
/*    */   public int bindData(DmMsgSend msg, int irow, int icol, boolean forBatch) throws SQLException
/*    */   {
/* 29 */     byte[] ret = null;
/* 30 */     Clob clob = ((Clob[])this.pstmt.m_paramObjects[icol])[irow];
/* 31 */     String serverEncoding = this.pstmt.connection.getServerEncoding();
/* 32 */     String str = "";
/*    */     
/* 34 */     long length = clob.length();
/* 35 */     if (this.destDType == 19) {
/* 36 */       if (length > 2048L) {
/* 37 */         return -1;
/*    */       }
/* 39 */       str = clob.getSubString(1L, (int)length);
/* 40 */       ret = Convertion.getBytes(str, serverEncoding);
/* 41 */       if (ret.length > 2048) {
/* 42 */         return -1;
/*    */       }
/*    */     }
/*    */     
/* 46 */     switch (this.destDType) {
/*    */     case 2: 
/*    */     case 19: 
/* 49 */       str = clob.getSubString(1L, (int)length);
/* 50 */       break;
/*    */     default: 
/* 52 */       DBError.throwSQLException(6007);
/*    */     }
/*    */     
/* 55 */     ret = Convertion.getBytes(str, serverEncoding);
/*    */     
/* 57 */     return msg.appendBytesWithLen2(ret, 0, ret.length);
/*    */   }
/*    */   
/*    */   public int bindLobCyc(DmMsgSend lobMsg, int irow, int icol) throws SQLException
/*    */   {
/* 62 */     Clob lob = ((Clob[])this.pstmt.m_paramObjects[icol])[irow];
/* 63 */     int maxLen = 8000;
/* 64 */     long lobLen = lob.length();
/*    */     
/* 66 */     if (this.offset_var > lobLen) {
/* 67 */       clearVars();
/* 68 */       return 0;
/*    */     }
/*    */     
/* 71 */     if (this.offset_var == -1) {
/* 72 */       this.offset_var = 1;
/*    */     }
/* 74 */     String serverEncoding = this.pstmt.connection.getServerEncoding();
/* 75 */     String str = lob.getSubString(this.offset_var, maxLen);
/* 76 */     this.offset_var += str.length();
/*    */     
/* 78 */     byte[] ret = Convertion.getBytes(str, serverEncoding);
/*    */     
/* 80 */     return lobMsg.appendOffRowBytes(ret, 0, ret.length, this.new_lob_flag, 
/* 81 */       str.length());
/*    */   }
/*    */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\driver\DmClobBinder.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */